package com.hd.service.test;

import java.util.Date;
import java.util.List;

import com.hd.common.DataPage;
import com.hd.persistence.model.Customer;
import com.hd.utils.HdException;

public class CustomerManagerTestCase extends BaseTest {
	
	//保存实体
//	public void testSaveCustomer() throws HdException {
//		for ( int i = 0; i < 10; i++ ) {
//			Customer customer = new Customer();
//			customer.setUnitName("单位名称" + i);
//			customer.setUnitForShort("dwjc" + i);
//			customer.setAddress("无锡市");
//			customer.setDistrict("滨湖区");
//			customer.setUnitKind("政府机构");
//			customer.setContactWay("0510-85910687");
//			customer.setStatus(0);
//			purchaseManager.saveCustomer(customer);
//		}
//	}
	
	//分页查询
//	public void testPageQueryCustomers() throws HdException {
//		DataPage<Customer> dataPage = purchaseManager.pageQueryCustomers(1, 10);
//		System.out.println("查询总数为:" + dataPage.getTotalCount());
//		List<Customer> customers = dataPage.getData();
//		for ( Customer customer : customers ) {
//			System.out.println(customer.getCustomerId() + " " + customer.getUnitName());
//		}
//	}
	
	//列出所有客户
//	public void testListCustomers() throws HdException{
//		List<Customer> customers = purchaseManager.listCustomers();
//		for ( Customer customer : customers ) {
//			System.out.println(customer.getCustomerId() + " " + customer.getUnitName());
//		}
//	}
	
	//根据条件分页查询
	public void testPageQueryCustomers2() throws HdException {
		DataPage<Customer> dataPage = purchaseManager.pageQueryCustomers(1L, new Date(), new Date(), "单位名称", 1, 100);
		System.out.println("查询总数为:" + dataPage.getTotalCount());
		List<Customer> customers = dataPage.getData();
		for ( Customer customer : customers ) {
			System.out.println(customer.getCustomerId() + "\t" + customer.getUnitName());
		}
	}

}
